package com.atguigu.springcloud.alibaba.controller;

import com.atguigu.springcloud.entities.CommonResult;
import com.atguigu.springcloud.entities.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public class PaymentController {
    @Value("${server.port}")
    private String serverPort;

    public static HashMap<Long, Payment> hasMap = new HashMap<>();

    static {
        hasMap.put(1L, new Payment(1L, "28a2o23234p1231231k2323232j34344"));
        hasMap.put(1L, new Payment(2L, "28a2o23234p1231231k2323232j34346"));
        hasMap.put(1L, new Payment(3L, "28a2o23234p1231231k2323232j34348"));
    }

    @GetMapping("/paymentSQL/{id}")
    public CommonResult<Payment> getPayment(@PathVariable("id") Integer id) {
        Payment payment = hasMap.get(id);
        CommonResult<Payment> result = new CommonResult<>(200, "from mysql,serverPort:" + serverPort);
        return result;
    }
}
